<?php

namespace App\Admin\Forms\Tenant;

use App\Wen\Utils\FieldUtils;
use App\Wen\Utils\Settings;
use Dcat\Admin\Contracts\LazyRenderable;
use Dcat\Admin\Traits\LazyWidget;
use Dcat\Admin\Widgets\Form;

class TenantUrlReplaceForm extends Form implements LazyRenderable
{
    use LazyWidget;

    public function handle(array $input)
    {
        Settings::set('doc_url_replace_list', $input['doc_url_replace_list'], true);
        return $this->response()
            ->success('配置成功')
            ->refresh();
    }

    public function form()
    {
        $this->html(function () {
            return '<div style="background-color: powderblue;color: #414750;padding: 10px;border-radius: 5px;">key: 要替换掉的链接<br/>value: 新链接</div>';
        }, '');
        $this->keyValue('doc_url_replace_list', '链接或文本替换')->default(Settings::get('doc_url_replace_list', []));
    }

}
